//2.系统接口完成
//我想要写一个 kill 命令, 模拟实现
#include<iostream>
#include<string>
#include<cstdlib>
#include<sys/types.h>
#include<signal.h>
#include<cstring>
#include<cerrno>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;


void handler(int signo)
{
    cout << "我是一个进程, 刚刚获取了一个信号: " << signo << endl;
}

static void Usage(const std::string& proc)
{
    cout << "Usage:\n\t" << proc << " signo pid" << endl;
}

int main(int argc, char* argv[])
{
    if(argc != 3)
    {
        Usage(argv[0]);
        exit(1);
    }
    if(kill(static_cast<pid_t>(atoi(argv[2])), atoi(argv[1])) == -1)
    {
        cerr << "kill:" << strerror(errno) << endl;
        exit(2);
    }

    return 0;
}